#include<string>
using namespace std;

class Solution {
public:
    bool judge(char x, char y)
    {
        if ((x == '0' && y == 'P') || (x == 'P' && y == '0'))
            return false;
        if (x == y)
            return true;
        if (x + 32 == y || x - 32 == y)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    bool judge_chara_num(char c)
    {
        if (c < 48 || (c > 57 && c < 65) || (c > 90 && c < 97) || (c > 122))
        {
            return true;
        }
        else
        {
            return false;
        }

    }

    bool isPalindrome(string s) {
        if (s == " ")
            return true;
        int begin = 0;
        int end = s.size() - 1;
        while (begin <= end)
        {
            while (judge_chara_num(s[begin]) && begin <= (s.size() - 1))
            {
                begin++;
                if (begin > (s.size() - 1))
                    break;
            }

            while (judge_chara_num(s[end]) && end >= 0)
            {
                end--;
                if (end < 0)
                    break;
            }

            if (end < 0 || begin >= (s.size() - 1))
            {
                return true;
            }

            if (judge(s[begin], s[end]) == false)
            {
                return false;
            }
            else
            {
                begin++;
                end--;
            }
        }
        return true;

    }

};